# for 循环

"""
for:
    for i in range(n):
        循环体内容
range(stop):
    左闭右开
range(start,stop)：
    左闭右开
"""

# 打印1-10  range :从0->n-1
for i in range(1, 11):
    print("---->", i)
# 步长 2
for i in range(1, 11, 2):
    print("---->", i)
print("**" * 20)

# 1-50 的累加和
sum1 = 0
for i in range(51):
    sum1 += i
print("1-50的累加和：", sum1)

# 输入用户名和密码最多输入三次，如果三次登录失败，提示账号被锁定

username = "admin"
password = "1234"
for i in range(3):
    name = input("请输入用户名：")
    pwd = input("请输入密码：")
    if username == name and password == pwd:
        print("登录成功！")
        break
    else:
        print("用户名或密码错误,您还有%d次机会" % (2 - i))
        continue
    print("三次登录失败，账号被锁定！")

'''
for....else
if 条件：
    pass
else:
    pass
for i in range(n)
    循环体
else:
    如果上面for循环没有中断，这块就会执行；过break  就会执行else
'''
username = "admin"
password = "12345"
for i in range(3):
    name = input("请输入用户名：")
    pwd = input("请输入密码：")
    if username == name and password == pwd:
        print("登录成功！")
        break
    else:
        print("用户名或密码错误,您还有%d次机会" % (2 - i))
        continue
else:
    print("三次登录失败，账号被锁定！")

